package com.example.controller;

import com.example.model.Product;
import com.example.model.Property;
import com.example.service.ProductService;
import com.example.service.PropertyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.List;
@Controller
@RequestMapping
public class ProductController {

    @Autowired
    ProductService productService;

    @Autowired
    PropertyService propertyService;
    @GetMapping("product")
    public String product(Integer id, Model model) throws Exception {
        Product product = productService.getById(id);
        List <Property> properties = propertyService.findById(id);
        model.addAttribute("product",product);
        model.addAttribute("property",properties);
        return "product";
    }

}
